<template>
	<view>
		<u--input placeholder="请输入标题" border="bottom" v-model="signBackEntity.title" clearable></u--input>
		<u-gap height=15></u-gap>
		<u--textarea v-model="signBackEntity.content" placeholder="请输入内容"></u--textarea>
		<view class="u-page__item">

			<u-cell-group>
				<u-cell title="开始时间" :isLink="true" @click="starts()"></u-cell>
			</u-cell-group>


		</view>

		<u-gap height=45></u-gap>

		<view class="u-demo-block__content"
			style="padding: 15px; flex-direction: column;align-items: stretch;flex-wrap: nowrap; border-radius: 200rpx;"
			@click="submit()">
			<u-button text="发布日程" size="large" color="pink" type="success"></u-button>
		</view>

		<u-datetime-picker :show="show4" v-model="signBackEntity.startTime" mode="time" closeOnClickOverlay
			@confirm="confirm" @cancel="cancel" @change="change" @close="close"></u-datetime-picker>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				value1: '',
				show4: false,

				signBackEntity: {
					title: '',
					content: '',
					startTime: '02:23',




				},
				flag: true
			}
		},
		onLoad(params) {
			this.signBackEntity.signId = params.id
		},
		methods: {
			starts() {
				this.show4 = !this.show4
			},
			close() {
				this.show4 = !this.show4
			},
			cancel() {
				this.show4 = !this.show4
			},
			confirm(e) {
				this.show4 = !this.show4

				console.log(e);

			},
			change(e) {
				// console.log('change', e)
			},
			navigateBack() {
				uni.navigateBack()
			},
			submit() {
				if (this.flag) {
					if (!this.signBackEntity.title) {
						uni.showToast({
							title: '请输入标题',
							icon: 'none'
						});
						return;
					}
					if (!this.signBackEntity.content) {
						uni.showToast({
							title: '请输入内容',
							icon: 'none'
						});
						return;
					}

					if (!this.signBackEntity.signId) {
						uni.showToast({
							title: '请选择打卡id',
							icon: 'none'
						});
						return;
					}
					if (!this.signBackEntity.startTime) {
						uni.showToast({
							title: '请选择开始时间',
							icon: 'none'
						});
						return;
					}
					this.flag = !this.flag


					uni.$u.http.post('/app/sign/reback', this.signBackEntity).then(
						(res) => {

							uni.showToast({
								title: '设置任务成功',
								icon: 'none'
							});


							setTimeout(function() {
								uni.navigateTo({
									url: '../Clock'
								})
							}, 2000);

						}
					)
				} else {
					uni.showToast({
						title: '正在提交，请稍等片刻',
						icon: 'none'
					});
				}

			}

		}
	}
</script>

<style scoped>
	page {}

	.uni-input-wrapper input {
		font-size: 28rpx;
		border-radius: 5rpx;
		padding: 20rpx 15rpx;
		box-shadow: 0 0 2rpx #000000;
	}

	.u-demo-block__content {
		flex-direction: row;
		flex-wrap: wrap;
		align-items: center;
	}
</style>
